import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { NavigationComponent } from './../navigation/navigation.component';
import { LoginComponent } from './../login/login.component';
import { LoginGuard } from './guard/login-guard';
import { ErrorComponent } from './../error/error.component';

const routes: Routes = [
    { path: '', redirectTo: '/dashbord', pathMatch: 'full' },
    {
        path: '',
        component: NavigationComponent,
        // canActivate: [LoginGuard],
        children: [
            {
                path: 'dashbord',
                loadChildren: './../dashbord/dashbord.module#DashbordModule',
                data: {
                    nav: {
                        name: '首页',
                        path: 'dashbord',
                        icon: 'file'
                    }
                }
            }, {
                path: 'charts',
                loadChildren: './../charts/charts.module#ChartsModule',
                data: {
                    nav: {
                        name: '图表',
                        path: 'charts',
                        icon: 'bar-chart',
                        children: [
                            { name: 'echarts图表', path: 'echarts' },
                            { name: 'antv图表', path: 'antv' }
                        ]
                    }
                }
            }, {
                path: 'exception/:status',
                component: ErrorComponent,
                data: {
                    nav: {
                        name: '错误页',
                        path: 'exception',
                        icon: 'warning',
                        children: [
                            { name: '403', path: '403' },
                            { name: '404', path: '404' },
                            { name: '500', path: '500' }
                        ]
                    }
                }
            }, {
                path: 'im',
                loadChildren: './../web-im/web-im.module#WebImModule',
                data: {
                    nav: {
                        name: '即时通讯',
                        path: 'im',
                        icon: ''
                    }
                }
            }
        ]
    },
    {
        path: 'login',
        component: LoginComponent
    },
    { path: 'exception/:status', component: ErrorComponent }
];

@NgModule({
    declarations: [],
    imports: [
        RouterModule.forRoot(routes)
    ],
    exports: [RouterModule]
})

export class AppRouting { }
